import query from '@dfeidao/atom-nodejs/db/query';
import log from '@dfeidao/atom-nodejs/logger/log';
import { systemid } from '../../atom/config';
interface Message {
	filter: {
		company_no: string
	};
}

// 依据得到的“企业编号”取<工厂>表，得到“工厂编号”、“工厂名称”，


export default async function atom(msg: Message, action_id: string, session_id: string) {
	log(`Service begin`);
	// todo查询
	const { exec, prepare } = query(action_id, session_id, systemid);
	prepare('factory', ['_id',
		'productid',
		'factory_no',
		'factory_name',
		'factory_address',
		'factory_principle',
		'contact',
		'contacts_tel_one',
		'contacts_tel_two',
		'company_no'
	], { company_no: { $like: msg.filter.company_no } }, 100, 1, [], []);


	const [rs] = await exec();


	log(`Service end`);
	return rs;
}
